home *** CD-ROM | disk | FTP | other *** search
/ Windows News 2010 Summer - Disc 1 / WN_Ete2010_CD1.iso / Onglet5 / Weezo / Weezo setup.exe / {code_appDir} / www / res / administration / config / wallpaper.php < prev    next >
PHP Script  |  2010-05-19  |  8KB  |  217 lines

  1. <?php
  2. /**
  3.  * Accounts remote configuration
  4.  *
  5.  * PHP version 5
  6.  *
  7.  * LICENSE: This source file is subject to version 3.0 of the PHP license
  8.  * that is available through the world-wide-web at the following URI:
  9.  * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
  10.  * the PHP License and are unable to obtain it through the web, please
  11.  * send a note to license@php.net so we can mail you a copy immediately.
  12. *
  13.  * @category   NA
  14.  * @package    NA
  15.  * @author     Nicolas Bruley / Peer 2 World <contact@weezo.net>
  16.  * @copyright  2005-2009 Nicolas Bruley / Peer 2 World
  17.  * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
  18.  * @version    CVS: $Id:$
  19.  * @link       http://www.weezo.net
  20.  * @since      File available since Release 2.0.0
  21.  */
  22.  
  23. if(cfUGetVar('accountType')!='singleUser') die('unauthorized access');
  24.  
  25. define('PREVIEW_WIDTH',70);
  26. define('PREVIEW_HEIGHT',60);
  27.  
  28. require_once(INCLUDE_DIR.'outputFunctions.php');
  29. require_once(INCLUDE_DIR.'applicationConfigFunctions.php');
  30.  
  31. $position=(cfUGetVar('wallpaperPosition'))?cfUGetVar('wallpaperPosition'):'centered';
  32.  
  33. // Initialize data
  34. outControlSetData(array('wallpaperPosition'=>$position));
  35.  
  36. /*
  37.  ***************************************************************************************************************************
  38.  * Process POST commands
  39.  ***************************************************************************************************************************
  40.  */
  41.  
  42. $wallpaperPositionControl=outControl('wallpaperPosition',
  43.     dataList,'centered',
  44.     array('stretched','centered','tiled'),
  45.     array(
  46.         array(outImage(outIcon('wpStretched'),false,false,'vertical-align:bottom;margin-right:0.2em'),'stretched',cfCaption('configWPStretched')),
  47.         array(outImage(outIcon('wpCentered'),false,false,'vertical-align:bottom;margin-right:0.2em'),'centered',cfCaption('configWPCentered')),
  48.         array(outImage(outIcon('wpTiled'),false,false,'vertical-align:bottom;margin-right:0.2em'),'tiled',cfCaption('configWPTiled'))
  49.     )
  50. );
  51.  
  52. if(cfIsAsync()){
  53.     cfAsyncHeader();
  54.  
  55.     // Wallpaper position
  56.     if(outControlGetData($options) && !isset($_POST['setBackground'])) {
  57.         foreach ($options as $k=>$v) cfUSetVar($k,$v);
  58.         $modified=true;
  59.     }
  60.  
  61.     // Wallpaper image
  62.     if(isset($_POST['setWP']) && ($_POST['setWP']=='no' || $_POST['setWP']=='theme' || file_exists($cfn=cfJoinPathFile(cfAppDocRoot().'/gfx/wallpapers/',$_POST['setWP'])))){
  63.         if($_POST['setWP']!=cfUGetVar('wallpaper')){
  64.             if($_POST['setWP']=='no' || $_POST['setWP']=='theme') $cfn=$_POST['setWP'];
  65.             cfUSetVar('wallpaper',basename($cfn));
  66.             $options['wallpaper']=basename($cfn);
  67.             $modified=true;
  68.         }
  69.     }
  70.     if(isset($modified)){
  71.         $wp=cfUGetVar('wallpaper');
  72.     }
  73.  
  74.     // Background color
  75.     if(isset($_POST['setBackground'])){
  76.         $_POST['setBackground']=str_replace('#','sharp',str_replace(chr(32),'',$_POST['setBackground']));
  77.         if(preg_match('/^sharp[0-9a-fA-f]{6}$/', $_POST['setBackground'])||preg_match('/^rgb\([0-9]{1,3},[0-9]{1,3},[0-9]{1,3}\)$/i', $_POST['setBackground'])){
  78.             $_POST['setBackground']=str_replace('sharp','#',$_POST['setBackground']);
  79.             if(cfUGetVar('desktopColor')!=$_POST['setBackground']) $modified=true;
  80.             cfUSetVar('desktopColor',$_POST['setBackground']);
  81.             $options['desktopColor']=$_POST['setBackground'];
  82.         }
  83.     }
  84.  
  85.     // Commit to user configuration
  86.     if(isset($modified)){
  87.         require_once(INCLUDE_DIR.'resourceConfigFunctions.php');
  88.         rcUserSaveValues($options);
  89.     }
  90.     //echo cfAsyncXMLJSaction('setColPickVisibility()');
  91.     
  92.     echo $outControlAsyncResponse;
  93.     die (cfAsyncFooter());
  94. }
  95.  
  96.  
  97. $wp=cfUGetVar('wallpaper');
  98.  
  99. cfInsertHEAD(false);
  100. ?>
  101. <script type="text/javascript">
  102. var selected="<?php echo $wp?>";
  103. var position="<?php echo $position?>";
  104.  
  105. var colPickOverCB,colPickClickCB;
  106. function colPickMO(e){
  107.     var c=(e&&e.target)?e.target.style.backgroundColor:((event&&event.srcElement)?event.srcElement.style.backgroundColor:false);
  108.     if(c) cpOverCB(c)
  109. }
  110. function colPickC(e){
  111.     var c=(e&&e.target)?e.target.style.backgroundColor:((event&&event.srcElement)?event.srcElement.style.backgroundColor:false);
  112.     if(c) cpClickCB(c)
  113. }
  114. function colPick(n,overCB,clickCB){
  115.     cpOverCB=overCB;cpClickCB=clickCB;
  116.     var nb=0,r,g,b;
  117.     var out='<table class="cp">';
  118.     for(g=0;g<15;g+=3)    for(r=0;r<=15;r+=3)    for(b=0;b<=15;b+=3){
  119.         nb++;
  120.         if((nb%18)==1) {
  121.             gr=Math.floor(256*(nb-1)/162);
  122.             out+='<tr><td style="background:rgb('+(gr)+','+(gr)+','+(gr)+')"> </td><td> </td>\n';;
  123.         }
  124.         out+='<td style="background:rgb('+(r*16)+','+(g*16)+','+(b*16)+')"> </td>\n';
  125.         if((nb%18)==0) out+='</tr>';
  126.     }
  127.     n.innerHTML=out+'</table>';
  128.     if(overCB) n.onmouseover=colPickMO;
  129.     if(clickCB) n.onclick=colPickC;
  130. }
  131. function cpmo(col){}
  132. // Color changed
  133. function cpc(col){
  134.     setBackgroundColor(col);
  135.     sendData('setBackground='+col.replace(/#/,'sharp'))
  136. }
  137. // Wallpaper changed
  138. function setWP(node,name){
  139.     if(selected==name) return;
  140.     selected=name;
  141.     var n=dgi('cont').firstChild,src=(name=='theme'||name=='no')?name:'/gfx/wallpapers/'+name;
  142.     while(n){n.className='ts';n=n.nextSibling}
  143.     node.className="tss";
  144.     
  145.     setColPickVisibility();
  146.     setWallpaper(src,position);
  147.     sendData('setWP='+name);
  148. }
  149. // Wallpaper position changed
  150. function asUpdtFunction(k,v){
  151.     if(k!='wallpaperPosition') return;
  152.     position=v;
  153.     var src=(selected=='theme'||selected=='no')?selected:'/gfx/wallpapers/'+selected;
  154.     setWallpaper(src,position);
  155. }
  156.  
  157. function unsel(n){if(n.className.substr(0,3)=='tss') n.className='tss'; else n.className='ts';}
  158. function sel(n){if(n.className.substr(0,3)=='tss') n.className='tss h'; else n.className='ts h';}
  159.  
  160. function setWallpaper(src,position){if(parent && parent.setWallpaper) parent.setWallpaper(src,position);}
  161. function setBackgroundColor(c){if(parent && parent.setBackgroundColor) parent.setBackgroundColor(c);}
  162.  
  163. function setColPickVisibility(){
  164.     if(selected=='no' || (dgn("asUpdtwallpaperPosition",1).checked && selected!='theme') && selected.substr(0,1)!='-') {
  165.         dgi('cpF').style.display='';
  166.     }
  167.     else dgi('cpF').style.display='none';
  168.  
  169.     dgi("wallpaperPosition").style.visibility=((dgi('noWP').className.substr(0,3)=='tss'||dgi('theme').className.substr(0,3)=='tss')?"hidden":"")
  170.     return true;
  171. }
  172. function init(){
  173.     colPick(dgi("cp"),null,cpc);
  174.     setColPickVisibility();
  175. }
  176. </script>
  177. <style type="text/css">
  178. .cp{table-layout:fixed;cursor:pointer}
  179. .cp td {width:10px;height:10px;margin:1}
  180. .tss{background:#CCE;border:1px solid #CCC;padding:9px;margin:3px;vertical-align:middle;text-align:center;color:black}
  181. .ts{background:white;border:1px solid #CCC;padding:9px;margin:3px;vertical-align:middle;text-align:center;color:black}
  182. .tstxt{background:white;border:1px solid #DDD}
  183. .h{background:#DDF}
  184. </style>
  185. </head>
  186. <body onload="init()">
  187. <center id="wallpaperPosition" style="<?php echo (($wp=='no'||$wp=='theme')?'visibility:hidden':'');?>">
  188. <?php
  189. echo $wallpaperPositionControl;
  190. ?>
  191. </center>
  192. <div id="cont" style="">
  193. <?php
  194.  
  195. // No wallpaper
  196. echo '<fieldset id="noWP" class="'.(($wp=='no')?'tss':'ts').'" style="display:inline" onmouseover="sel(this)" onmouseout="unsel(this)" onclick="setWP(this,\'no\')">';
  197. echo '<div class="tstxt smallFont" style="width:'.PREVIEW_WIDTH.';height:'.PREVIEW_HEIGHT.'"><div style="padding-top:25%">'.cfCaption('configWPNo').'</div></div>';
  198. echo '</fieldset>';
  199.  
  200. // Theme default
  201. echo '<fieldset id="theme" class="'.(($wp=='theme')?'tss':'ts').'" style="display:inline" onmouseover="sel(this)" onmouseout="unsel(this)" onclick="setWP(this,\'theme\')">';
  202. echo '<div class="tstxt" style="width:'.PREVIEW_WIDTH.';height:'.PREVIEW_HEIGHT.'"><div style="padding-top:35%">'.cfCaption('genTheme').'</div></div>';
  203. echo '</fieldset>';
  204.  
  205. // Wallpapers
  206. foreach (glob(cfAppDocRoot().'/gfx/wallpapers/*.{gif,jpg,jpeg,png}',GLOB_BRACE) as $cfn) {
  207.     if(cfGetBrowser()=='ie') echo '<span class="'.((basename($cfn)===$wp)?'tss':'ts').'" style="display:inline-block" onmouseover="sel(this)" onmouseout="unsel(this)" onclick="setWP(this,\''.basename($cfn).'\')"><img src="'.cfExtGFX('/gfx/wallpapers/'.basename($cfn),PREVIEW_WIDTH,PREVIEW_HEIGHT).'" style="visibility:hidden" onload="fade(this)"></span>';
  208.     else echo '<img class="'.((basename($cfn)===$wp)?'tss':'ts').'" src="'.cfExtGFX('/gfx/wallpapers/'.basename($cfn),PREVIEW_WIDTH,PREVIEW_HEIGHT).'" style="visibility:hidden" onmouseover="sel(this)" onmouseout="unsel(this)" onclick="setWP(this,\''.basename($cfn).'\')" onload="fade(this)">';
  209. }
  210.  
  211. ?>
  212. </div>
  213. <div class="frame1" id="cpF">
  214. <div class="frame1Header"><?php echo cfCaption('backgroundColor');?></div>
  215. <center id="cp"></center>
  216. </div>
  217. </body>